package com.itheima.web.request; /**
 * @author Xiao
 * @date 2021/8/29
 */

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
/**请求参数中文乱码问题：POST*/
@WebServlet(name = "RequestDemo06", value = "/demo06")
public class RequestDemo06 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1. 解决POST请求参数的中文乱码问题 getReader()
        // 设置字符输入流的编码，设置的字符集要和页面保持一致
        request.setCharacterEncoding("UTF-8");
        String username = request.getParameter("username");
        System.out.println(username);   //张三
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
